package com.kongge.formlike.service.rule;

import android.text.TextUtils;

import com.kongge.formlike.service.check.ICheckItem;

import java.util.List;

/**
 * author:kongge
 * date:2018/7/21
 * layout:
 * description:
 */

public class RuleNotNull extends AbsRule{

    private boolean isOpen;

    @Override
    public void setParam(List<Object> paramList) {
        super.setParam(paramList);
        if (paramList != null && paramList.size() > 0) {
            Object item = paramList.get(0);
            if (item instanceof Boolean) {
                isOpen = (Boolean) item;
            }
        }
    }

    @Override
    public boolean check(ICheckItem checkItem) {
        if (!isOpen) {
            return true;
        }
        if (checkItem != null) {
            String checkStr = checkItem.getCheckContent();
            return !TextUtils.isEmpty(checkStr);
        }
        return false;
    }
}
